package com.ywl.designpattern.strategy;

/**
 * 4.最后,我们可以这样使用这个策略模式
 * @author yuwl
 * @description
 * @since 2024-06-27 16:04
 */
public class StrategyPatternDemo {

    public static void main(String[] args) {
        ShoppingCart cart = new ShoppingCart();

        // 使用信用卡支付
        cart.setPaymentStrategy(new CreditCardStrategy("John Doe", "1234567890123456"));
        cart.checkout(100);

        // 使用PayPal支付
        cart.setPaymentStrategy(new PayPalStrategy("johndoe@example.com"));
        cart.checkout(200);
    }
}
